const app = getApp()
import { request} from '../../utils/request';
import config from '../../utils/config'
Page({
    data: {
        blocks: [{ padding: '13px', background: '#617df2' }],
        prizes: [
            { fonts: [{ text: '0', top: '10%' }], background: '#e9e8fe',range:30 },
            { fonts: [{ text: '1', top: '10%' }], background: '#b8c5f2',range:20 },
            { fonts: [{ text: '2', top: '10%' }], background: '#e9e8fe',range:10 },
            { fonts: [{ text: '3', top: '10%' }], background: '#b8c5f2',range:10 },
            { fonts: [{ text: '4', top: '10%' }], background: '#e9e8fe',range:10 },
            { fonts: [{ text: '5', top: '10%' }], background: '#b8c5f2',range:10 },
            { fonts: [{ text: '6', top: '10%' }], background: '#b8f5f2',range:1 },
        ],
        buttons: [
            { radius: '50px', background: '#617df2' },
            { radius: '45px', background: '#afc8ff' },
            {
                radius: '40px', background: '#869cfa',
                pointer: true,
                fonts: [{ text: '开始\n抽奖', top: '-20px' }]
            },
        ],
    },
    start () {
        // 获取抽奖组件实例
        const child = this.selectComponent('#myLucky')
        // 调用play方法开始旋转
        child.lucky.play()
        // 用定时器模拟请求接口
        setTimeout(() => {
            // 3s 后得到中奖索引 (假设抽到第0个奖品)
            // const index = 1
            // 调用stop方法然后缓慢停止
            child.lucky.stop()
        }, 3000)
    },
    end (event) {
        // 中奖奖品详情
        console.log(event.detail)
    },
    test(){
        request({
            url:'/miniprogram/wechatpay/pay',
        }).then(res=>{
            wx.requestPayment({
                timeStamp: res.data.timeStamp,
                nonceStr: res.data.nonceStr,
                package: res.data.package,
                signType: res.data.signType,
                paySign: res.data.paySign,
                success(rel) {
                    
                },
                fail(err) {
                    
                }
            })
        })
    }
});